﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Enterprise.Management.Caches;

namespace Enterprise.Management.Business
{
    public class RewardsPunishmentBLL : BaseBLL
    {
        public DP_Reward_Info Get(int id)
        {
            return DataContext.DP_Reward_Info.First(m=>m.RwdInf_ID == id);
        }

        public bool Add(DP_Reward_Info info)
        {
            info.RwdInf_CtgrID = BranchCategoryCache.BranchCategoryId.Value;
            info.ModifiedBy = HtmlCache.GetUser().User_ID;
            info.ModifiedDate = DateTime.Now;
            DataContext.DP_Reward_Info.InsertOnSubmit(info);
            return Submit();
        }

        public bool Update(DP_Reward_Info info)
        {
            info.ModifiedBy = HtmlCache.GetUser().User_ID;
            info.ModifiedDate = DateTime.Now;
            return Submit();
        }

        public bool Delete(int id)
        { 
            var rp = Get(id);
            DataContext.DP_Reward_Info.DeleteOnSubmit(rp);
            return Submit();
        }
    }
}